package com.longsunhd.yum.buffalo.network;

import com.longsunhd.yum.buffalo.network.api.BuffaloApi;
import com.longsunhd.yum.buffalo.network.api.MedicationApi;
import com.longsunhd.yum.buffalo.network.api.MilkApi;
import com.longsunhd.yum.buffalo.network.api.UserApi;


public class Network {
   private static UserApi userApi;
   private static MedicationApi medicationApi;
    private static BuffaloApi buffaloApi;
    private static MilkApi milkApi;

    /**
     * 账户相关接口
     * @return
     */
    public static UserApi getAccountApi() {
        if (userApi == null) {
            userApi=      ApiFactory.newInstance().getApi(UserApi.class);
        }
        return userApi;
    }
    /**
     * 账户相关接口
     * @return
     */
    public static UserApi getAccountApi(String token) {

       userApi=      ApiFactory.newInstance(token).getApi(UserApi.class);

        return userApi;
    }

    /**
     * 用药
     * @return
     */
    public static MedicationApi getMedicationApi(String token) {
        if (medicationApi == null) {
            medicationApi=      ApiFactory.newInstance(token).getApi(MedicationApi.class);
        }
        return medicationApi;
    }
    /**
     * 用药
     * @return
     */
    public static BuffaloApi getBuffaloApi(String token) {
        if (buffaloApi == null) {
            buffaloApi=      ApiFactory.newInstance(token).getApi(BuffaloApi.class);
        }
        return buffaloApi;
    }
    /**
     * 用药
     * @return
     */
    public static MilkApi getMilkApi(String token) {
        if (milkApi == null) {
            milkApi=      ApiFactory.newInstance(token).getApi(MilkApi.class);
        }
        return milkApi;
    }
}
